// 上传接口
const router = require('koa-router')()
const multer = require('koa-multer') // 上传模块

const { IMAGE_CONFIG, IMAGE_FILTER } = require('../utils/config')
const { C_upload } = require('../controller/index')

router.prefix('/upload')

// 图片上传实例
const upload_img = multer({ storage: IMAGE_CONFIG, fileFilter: IMAGE_FILTER })

// 图片上传接口
router.post('/image', upload_img.array('img', 5), C_upload.iupload_image)

// 修改头像的图片上传接口
router.post('/update_avatar', upload_img.single('avatar'), C_upload.update_avatar)

// 富文本编译器图片上传接口
router.post('/article_img', upload_img.single('editor'), C_upload.editor)




module.exports = router
